Imports System.Runtime.InteropServices
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms

''' <summary>
''' This class works in conjuction with ReportMatadata class and has the 
''' responsibility of creating an instance (through reflection) of the report class 
''' to show
''' </summary>
Public Interface IReportInstanceLoader
    Function getReportInstance(ByVal rm As ReportMatadata) As ReportClass
End Interface

Public Class ReportInstanceLoader
    Implements IReportInstanceLoader

    Public Function getReportInstance(ByVal rm As ReportMatadata) As  _
                    CrystalDecisions.CrystalReports.Engine.ReportClass _
                    Implements IReportInstanceLoader.getReportInstance

        Return CType(AppDomain.CurrentDomain.CreateInstanceAndUnwrap(rm.ReportAssemblyName, _
                            rm.FullyQualifiedResourcePath), ReportClass)

    End Function
End Class